<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="__JS__/jquery.js"></script>
    <script type="text/javascript" src="__JS__/user.js"></script>
    <link rel="stylesheet" type="text/css" href="__CSS__/pass.css" />
    <title>找回密码</title>
</head>
<body>
<div class="box">
    <a href="/" target="_blank"><img src="{$logo.login}" /></a>
    <div class="boxm">
        <div class="wrap">
            <div class="passType">
                <label><input type="radio" checked value="email" name="passType">邮箱找回</label>
                <label><input type="radio" value="phone" name="passType">手机找回</label>
            </div>
            <form action="{:U('Login/pass')}" method="post" name="myForm" id="myForm">
                <input type="hidden" value="email" name="type">
                <div id="email_show">
                    <img id="pic" src="__IMG__/email_pass1.gif" width="747" height="41" />
                    <p class="boxmt">请填写您已注册的邮箱号码:</p>
                    <ul class="all366C">
                        <li><input class="txt" name="val" type="text" style="width:300px;" /><span id="info">请您输入邮箱号码</span></li>
                        <li><input class="txt" name="captcha_code" id="captcha_code" type="text" style="width:100px;float:left; margin-right:10px" /><span><a href="javascript:;"><img style="float:left;" id="verfiy" class="verfiy" src="{:U('Login/verfiy')}" width="92" height="32"  /></a><a class="verfiy" style="cursor:pointer" >看不清？</a></span></li>
                        <li><a class="btnok" onclick="return sub();" href="javascript:;">下一步</a></li>
                    </ul>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $("input[name='passType']").click(function(){
            var v = $(this).val();
            if(v=='phone'){
                $("input[name='type']").val("phone");
                $("#pic").attr('src',"__IMG__/phone_pass1.gif");
                $(".boxmt").html("请填写您已注册的手机号码:");
                $("#info").html("请输入手机号码");
            }else{
                $("input[name='type']").val("email");
                $("#pic").attr('src',"__IMG__/email_pass1.gif");
                $(".boxmt").html("请填写您已注册的邮箱:");
                $("#info").html("请输入邮箱");
            }
        });
    });

    function sub(){
        var type = $("input[name='type']").val();
        var v = $("input[name='val']").val();
        if($("#captcha_code").val()==''){
            alert('验证码不能为空!');
            return false;
        }

        //判断邮箱
        if(type=='email'){
            if(v==''){
                alert('邮箱不能为空!');
                return false;
            }
            var reNum = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if(!reNum.test(v)){
                $("#info").css('color','red');
                $('#info').text('请输入正确的邮箱号码');
                return false;
            }
            $.post("{:U('Login/checkName')}",{'email':v},function(data){
                if(data.status==1){
                    $("#info").css('color','red');
                    $('#info').text('您填写的邮箱没有注册过');
                    return false;
                }else{
                    $("#myForm").submit();
                }
            });

        }
        //手机号码
        if(type=='phone'){
            if(v==''){
                alert('手机号码不能为空!');
                return false;
            }
            var reNum =/^0{0,1}(13[0-9]|15[5-9]|15[0-3]|177|18[5-9]|18[0-3])[0-9]{8}$/;
            if(!reNum.test(v)){
                $("#info").css('color','red');
                $('#info').text('请输入正确的手机号码');
                return false;
            }
            $.post("{:U('Login/checkName')}",{'mobile':v},function(data){
                if(data.status==1){
                    $("#info").css('color','red');
                    $('#info').text('您填写的手机号码还没有注册过');
                    return false;
                }else{
                    $("#myForm").submit();
                }
            });
        }
    }

</script>
</body>
</html>